<template>
  <div class="medtech-container">
    <!-- 顶部导航栏 -->
    <div class="medtech-header">
      <div class="header-content">
        <div class="brand">
          <img src="@/assets/logo.jpg" class="logo">
          <h1 class="brand-name">寒冬终将过去，春暖花会再开</h1>
        </div>
        <nav class="main-nav">
          <router-link to="/Forum" class="nav-item">
            <i class="icon icon-forum"></i>
            <span>病友交流圈</span>
          </router-link>
          <router-link to="/AI_helper" class="nav-item">
            <i class="icon icon-ai"></i>
            <span>AI小医聊</span>
          </router-link>
          <router-link to="/PersonalCenter" class="nav-item">
            <i class="icon icon-personal"></i>
            <span>个人中心</span>
          </router-link>
          <router-link to="/AboutUs" class="nav-item">
            <i class="icon icon-about"></i>
            <span>关于我们</span>
          </router-link>
          <a href="javascript:;" class="nav-item" @click="handleLogout">
            <i class="icon icon-logout"></i>
            <span>退出登录</span>
          </a>
        </nav>
      </div>
      <div class="tech-divider"></div>
    </div>

    <!-- 主内容区 -->
    <main class="medtech-main">
      <!-- 轮播图区域 -->
      <section class="tech-carousel">
  <div class="carousel-wrapper">
    <el-carousel :interval="5000" arrow="always" height="300px">
      <el-carousel-item v-for="(img, idx) in images" :key="idx">
        <div class="carousel-item-wrapper">
          <img :src="img" alt="轮播图" style="width: 100%; height: 100%; object-fit: cover;">
        </div>
      </el-carousel-item>
    </el-carousel>
  </div>
</section>
      <!-- 健康资讯区 -->
      <section class="health-info">
  <div class="info-card">
    <h3 class="section-title">健康科技快讯</h3>
    <ul class="info-list">
      <li class="info-item">AI辅助诊断准确率达95%</li>
      <li class="info-item">远程医疗技术突破距离限制</li>
      <li class="info-item">智能穿戴设备实时监测健康数据</li>
    </ul>
  </div>
</section>

<!-- 健康贴士 -->
<section class="health-tips">
  <div class="info-card">
    <h3 class="section-title">日常健康贴士</h3>
    <ul class="info-list">
      <li class="info-item">每日步行8000步可降低心血管疾病风险</li>
      <li class="info-item">充足睡眠有助于增强免疫力</li>
      <li class="info-item">均衡饮食应包含多种颜色的蔬果</li>
    </ul>
  </div>
</section>

      <!-- 功能卡片区 -->
      <section class="feature-cards">
        <!-- 热门话题 -->
        <div class="card-container">
          <h2 class="section-title">医疗热点资讯</h2>
          <div class="card-grid">
            <a 
              v-for="(topic, idx) in hotTopics" 
              :key="'topic'+idx"
              :href="topic.link"
              class="tech-card"
            >
              <div class="card-icon">
                <img :src="topic.icon" alt="icon">
              </div>
              <div class="card-content">
                <h3 class="card-title">{{topic.title}}</h3>
                <p class="card-desc">{{topic.description}}</p>
              </div>
              <div class="card-hover"></div>
            </a>
          </div>
        </div>

        <!-- 公益信息 -->
        <div class="card-container">
          <h2 class="section-title">医疗公益热帖</h2>
          <div class="card-grid">
            <a 
              v-for="(info, idx) in publicWelfareInfo" 
              :key="'info'+idx"
              :href="info.link"
              class="tech-card"
            >
              <div class="card-icon">
                <img :src="info.icon" alt="icon">
              </div>
              <div class="card-content">
                <h3 class="card-title">{{info.title}}</h3>
                <p class="card-desc">{{info.description}}</p>
              </div>
              <div class="card-hover"></div>
            </a>
          </div>
        </div>
      </section>

      <!-- 快速入口 -->
      <router-link to="/Forum" class="quick-entry">
        <div class="entry-content">
          <img src="../assets/icons/click.png" class="entry-icon">
          <span>病友交流论坛</span>
        </div>
      </router-link>
    </main>
  </div>
</template>

<script>
export default {
 name:'Index',
  data() {
    return {
      images: [
        require('@/assets/carousel1.jpg'),
        require('@/assets/carousel2.jpg'),
        require('@/assets/carousel3.jpg'),
      ],
      currentIndex: 0,
      hotTopics: [
      {
        icon: require('../assets/icons/medical consultation.png'),
          img: require('@/assets/img1.jpg'),
          title: '踝关节镜手术经验分享',
          link: 'https://www.zhihu.com/tardis/bd/art/696145838?source_id=1001',
          description: '分享一些关于踝关节镜手术的经验...'
        },
        {
          icon: require('../assets/icons/medical consultation.png'),
          img: require('@/assets/img2.jpg'),
          title: '医疗保险全攻略',
          link: 'https://health.baidu.com/m/detail/ar_3480587161583545461',
          description: '详细讲解医疗保险的相关知识...'
        },
        {
          icon: require('../assets/icons/medical consultation.png'),
          img: require('@/assets/img3.jpg'),
          title: '医保卡看病如何报销',
          link: 'https://www.66law.cn/laws/517479.aspx',
          description: '医保卡保险报销分类以及医保范围...'
        },
        {
          icon: require('../assets/icons/medical consultation.png'),
          img: require('@/assets/img4.jpg'),
          title: '如何防止慢性疾病',
          link: 'http://health.people.com.cn/n1/2017/0217/c14739-29087461.html',
          description: '八项策略措施发力慢性病防治...'
        }
      ],
      publicWelfareInfo: [
        {
          icon: require('../assets/icons/public welfare.png'),
          title: '北京医心公益服务中心',
          link: 'https://www.bjyxgy.org.cn/sy',
          description: '开展与健康领域相关科普宣传、专业培训、咨询服务...'
        },
        {
          icon: require('../assets/icons/public welfare.png'),
          title: '湖南省湘雅医学与健康基金会',
          link: 'https://yayijjh.csu.edu.cn/czxm/ylgyxm.html',
          description: '包含医疗救助项目、医疗公益项目...'
        },
        {
          icon: require('../assets/icons/public welfare.png'),
          title: '全面医疗救助渠道',
          link: 'https://mbd.baidu.com/newspage/data/dtlandingsuper?nid=dt_4040190957830965738&sourceFrom=search_a',
          description: '20种医疗救助渠道，帮你解决看病难题...'
        },
        {
          icon: require('../assets/icons/public welfare.png'),
          title: '中华慈善总会',
          link: 'https://www.chinacharityfederation.org/',
          description: '大病，贫困患者，医保报销不够的，看过来...'
        }
      ],
      healthTips: [
      "每日步行8000步可降低心血管疾病风险",
      "充足睡眠有助于增强免疫力", 
      "均衡饮食应包含多种颜色的蔬果"
    ]
    }
  },
  methods: {
    nextSlide() {
      this.currentIndex = (this.currentIndex + 1) % this.images.length
    },
    prevSlide() {
      this.currentIndex = (this.currentIndex - 1 + this.images.length) % this.images.length
    },
    goToSlide(index) {
      this.currentIndex = index
    },
    handleLogout() {
      if (confirm('确定要退出登录吗？')) {
        // 清除登录状态
        localStorage.removeItem('token');
        // 跳转到登录页面
        this.$router.push('/');
      }
    }
  },
  mounted() {
    setInterval(this.nextSlide, 5000)
  }
}
</script>

<style scoped>
/* 基础样式 */
.medtech-container {
  background: linear-gradient(135deg, #ffffff 0%, #adcfe3 100%);
  width: 100%;
  max-width: 100%;
  overflow-x: hidden; /* 防止水平滚动 */
}

/* 顶部导航栏 */
.medtech-header {
  background: linear-gradient(135deg, white 0%, white 20%, #3e92cc 60%, #3e92cc 100%) !important;
  padding: 0 !important;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  z-index: 10;
}

.header-content {
  padding: 10px 40px;
  display: flex;
  align-items: center;
  width: 100%;
  justify-content: space-between;
}
@media (min-width: 1200px) {
  .header-content {
    max-width: 1620px;
    margin: 0 auto;
  }
}
.brand {
  display: flex;
  align-items: center;
  margin-right: auto; /* 新增：使brand左对齐 */
}

.logo {
  height:80px;
  margin-right: 40px;
}

.brand-name {
  color: white;
  font-size: 1.8rem;
  font-weight: 500;
  text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}


.main-nav {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  margin-right:50px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: white;
  text-decoration: none;
  font-size: 1rem;
  font-weight: 500;
  position: relative;
  padding: 0.5rem 0;
  transition: all 0.3s ease;
}

.icon {
  display: inline-block;
  width: 20px;
  height: 20px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.icon-forum {
  background-image: url('../assets/icons/forum.png');
}

.icon-ai {
  background-image: url('../assets/icons/ai.png');
}

.icon-personal {
  background-image: url('../assets/icons/personal.png');
}

.icon-about {
  background-image: url('../assets/icons/about.png');
}

.icon-logout {
  background-image: url('../assets/icons/logout.png');
}
.nav-item::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background-color: #3e92cc;
  transition: width 0.3s ease;
}

.nav-item:hover {
  color: #d1e5f7;
}

.nav-item:hover::after {
  width: 100%;
}

.tech-divider {
  height: 1px;
  background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.3) 50%, rgba(255,255,255,0) 100%);
  margin-top: 1rem;
}

/* 主内容区 */
.medtech-main {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  box-sizing: border-box; /* 确保padding包含在宽度内 */
}

/* 轮播图 */
.tech-carousel {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  max-width: 1200px;
  margin: 30px auto;
}

.carousel-wrapper {
  margin-top: 0 !important;
  width: 100%;
  height: 300px;
  z-index: 1;
  overflow: hidden;
}
.carousel-item-wrapper {
  position: relative;
  height: 100%;
  cursor: pointer;
}

.carousel-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.5s ease;
}
.arrow, .carousel-indicators {
  display: none;
}
.carousel-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 30px;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  color: white;
}

.carousel-title {
  color: white;
  font-size: 2rem;
  font-weight: 600;
  margin: 0;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.arrow {
  position: absolute;
  top: 50%;
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.9);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateY(-50%);
  cursor: pointer;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transition: all 0.3s;
  border: none;
  color: #1a73e8;
  font-size: 20px;
  opacity:0.3;
}

.arrow:hover {
  background: white;
  box-shadow: 0 2px 12px rgba(0,0,0,0.2);
  opacity:0.5;
}

.prev {
  left: 20px;
}

.next {
  right: 20px;
}
.carousel-indicators {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
}

.indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255,255,255,0.5);
  cursor: pointer;
  transition: all 0.3s;
}

.indicator.active {
  background: white;
  transform: scale(1.2);
}


/* 健康资讯区 */
.health-info, .health-tips {
  /* 基础设置 */
  margin-bottom: 2rem;
  background-image: url("../assets/bg6.jpg");
  /* 新增背景控制属性 */
  background-size: cover;       /* 图片覆盖整个容器 */
  background-position: center; /* 图片居中显示 */
  background-repeat: no-repeat; /* 禁止重复平铺 */
  background-attachment: fixed; /* 固定背景（视需求可选） */
  
  /* 容器尺寸控制 */
  min-height: 200px;           /* 设置最小高度 */
  padding: 1.5rem;             /* 增加内边距 */
  border-radius: 8px;          /* 圆角效果 */
  
  
  /* 半透明遮罩增强可读性（可选） */
  position: relative;
}

/* 半透明遮罩实现（可选） */
.health-info::before, .health-tips::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
  z-index: 0;
}

/* 内容层级提升 */
.health-info > *, .health-tips > * {
  position: relative;
  z-index: 1;
}

.info-card {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.info-title {
  color: #0a2463;
  font-size: 1.25rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #e1e8ed;
}
.section-title {
  color: #0a2463;
  font-size: 1.25rem;
  margin-bottom: 1rem;
  position: relative;
  padding-left: 1rem;
}

.section-title::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background-color: #3e92cc;
  border-radius: 2px;
}


.info-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.info-item {
  padding: 0.75rem 0;
  color: #3a506b;
  position: relative;
  padding-left: 1.5rem;
}

.info-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #3e92cc;
}

/* 功能卡片区 */
.feature-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: 3rem;
}

.section-title {
  color: #0a2463;
  font-size: 1.25rem;
  margin-bottom: 1.5rem;
  position: relative;
  padding: 0 1rem; /* 左右都添加内边距 */
  display: inline-block; /* 使标题宽度自适应内容 */
}

.section-title::before,
.section-title::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 4px;
  background-color: #3e92cc;
  border-radius: 2px;
}

.section-title::before {
  left: 0;
}

.section-title::after {
  right: 0;
}


.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.tech-card {
  position: relative;
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  text-decoration: none;
  height: 140px;
  display: flex;
  align-items: center;
  padding: 1.5rem;
  border: 1px solid rgba(62, 146, 204, 0.1);
}

.tech-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 12px 28px rgba(0,0,0,0.12);
}

.card-icon {
  width: 56px;
  height: 56px;
  margin-right: 1.5rem;
  flex-shrink: 0;
  background: rgba(62, 146, 204, 0.1);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.card-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.card-title {
  color: #0a2463;
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
}

.card-desc {
  color: #5e6d82;
  font-size: 0.9rem;
  margin: 0;
  line-height: 1.5;
}

/* 新增卡片悬停效果 */
.card-hover {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(62,146,204,0.1) 0%, rgba(10,36,99,0.1) 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: -1;
}

.tech-card:hover .card-hover {
  opacity: 1;
}

/* 响应式调整 */
@media (max-width: 992px) {
  .feature-cards {
    grid-template-columns: 1fr;
  }
  
  .card-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 768px) {
  .card-grid {
    grid-template-columns: 1fr;
  }
  
  .tech-card {
    height: auto;
    flex-direction: column;
    text-align: center;
    padding: 1.5rem;
  }
  
  .card-icon {
    margin-right: 0;
    margin-bottom: 1rem;
  }
}
/* 快速入口 */
.quick-entry {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: linear-gradient(135deg, #0a2463 0%, #3e92cc 100%);
  color: white;
  padding: 1rem 1.5rem;
  border-radius: 50px;
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  z-index: 100;
}

.quick-entry:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 16px rgba(0,0,0,0.3);
}

.entry-content {
  display: flex;
  align-items: center;
}

.entry-icon {
  width: 24px;
  height: 24px;
  margin-right: 0.75rem;
}

/* 响应式设计 */
@media (max-width: 1200px) {
  .medtech-main {
    padding: 0 15px;
  }
  .feature-cards {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .medtech-main {
    padding: 0 10px;
  }
  
  .header-content {
    flex-direction: column;
    align-items: flex-start;
  }
  
  
  .carousel-title {
    font-size: 1.5rem;
  }
  
  .card-grid {
    grid-template-columns: 1fr;
  }
}
</style>